package com.his.patiinfobasic.controller;

import com.his.config.annotation.CurrentUser;

import com.his.dictorderfreq.entity.DictOrderFreq;
import com.his.login.entity.DictEmployee;
import com.his.patiinfobasic.service.PatiinfobasicService;
import com.his.patiinfobasic.vo.PatiinfobasicVo;
import com.his.patiinfobasic.vo.PatiinfobasicVoo;
import com.his.sysconfig.service.SysconfigService;

import com.xiao.common.controller.ResultBaseController;
import com.xiao.common.util.ResultUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author xiaoxiaoping
 * @Date 2020/2/6 11:21
 * @Version 1.0
 */
@RestController
@RequestMapping(value="/api/pati_basic")
public class PatiinfobasicController extends ResultBaseController {

    private  final Logger logger = (Logger) LoggerFactory.getLogger(this.getClass());
    @Resource
    private PatiinfobasicService patiinfobasicService;

    @PostMapping(value = "/save.do")
    public ResultUtil save(@CurrentUser DictEmployee dictEmployee,@RequestBody @Validated PatiinfobasicVo patiinfobasicVo){
        try{
            return this.success("保存成功！", patiinfobasicService.save(patiinfobasicVo,dictEmployee));
        }catch (Exception e){
            e.printStackTrace();
            logger.error(e.getMessage());
            return this.fail(e.getMessage(),null);
        }

    }

    @PostMapping(value = "/update.do")
    public ResultUtil update(@RequestBody @Validated PatiinfobasicVoo patiinfobasicVoo){
        try{
            patiinfobasicService.update(patiinfobasicVoo);
            return this.success("修改成功！",null);
        }catch (Exception e){
            e.printStackTrace();
            logger.error(e.getMessage());
            return this.fail(e.getMessage(),null);
        }

    }
    @GetMapping(value="/get_pati_by_id.do")
    public ResultUtil getPatiById(@CurrentUser DictEmployee dictEmployee,String patiId){
        try{
            return this.success("",patiinfobasicService.selectById(patiId));
        }catch (Exception e){
            e.printStackTrace();
            logger.error(e.getMessage());
            return this.fail(e.getMessage(),null);
        }
    }
}
